 <meta charset="utf-8">
 <div class="row" >
 <div  class="col-md-6">
  <div class="box">
            <div class="box-header with-border">
               <form id="organizationSearchFromA" role="form" class="form-inline">
              	<h4>属于该组织机构人员</h4> 
              	
              		<div class="form-group">
						<label class="control-label">姓名</label> <input name="perName"
							id="perName" type="text" placeholder="" class="form-control">
					</div>
					<div class="form-group">
						<label class="control-label">编号</label> <input name="perNum"
							id="perNum" type="text" placeholder="" class="form-control">
					</div>
					
                  <div class="form-group" id="roleId_div">
					<km-select id="role" host="baseServer" url="/auth/authRole/loadRoleList" vmodel="role" name="role"  label="所属角色"></km-select>
				</div> 
                  <button type="button"  class="btn btn-info pull-right m-t-n-xs" onclick="searchA();"><strong>查询</strong></button>
                </form>
            </div>
 <div class="box-body">
 	<div class="row">
 	  <div class="col-md-12">
 	                           <div class="btn-group " id="ownSysOrganizationToolbar" role="group">
                                    <button type="button" class="btn btn-default" onclick="removeFromOrganization();">
                                        <i class="glyphicon glyphicon-minus" aria-hidden="true"></i> 移除
                                    </button>
                           </div> 
                                
           <table id="ownOrganizationTable" data-mobile-responsive="true" ></table>
 	  </div>
 	</div>
 </div>
</div>
 </div>
 <div  class="col-md-6">
   <div class="box">
            <div class="box-header with-border">
               <form id="organizationSearchFormB" role="form" class="form-inline">
               <h4>不属于组织机构的用户</h4>
                		<div class="form-group">
						<label class="control-label">姓名</label> <input name="permName"
							id="permName" type="text" placeholder="" class="form-control">
					</div>
					<div class="form-group">
						<label class="control-label">编号</label> <input name="permNum"
							id="permNum" type="text" placeholder="" class="form-control">
					</div>
                    <div class="form-group" id="role_div">
					<km-select id="role" host="baseServer" url="/auth/authRole/loadRoleList" vmodel="role" name="role"  label="所属角色"></km-select>
				</div> 
                     <button type="button"  class="btn btn-info pull-right m-t-n-xs" onclick="searchB();"><strong>查询</strong></button>
                </form>
            </div>
 <div class="box-body">
 	<div class="row">
 	  <div class="col-md-12">
 	                       <div class="btn-group " id="notOwnSysOrganizationToolbar" role="group">
                                    <button type="button" class="btn btn-default" onclick="addToOrganization();">
                                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
                                    </button>
                           </div> 
                                
           <table id="notOrganizationTable" data-mobile-responsive="true" ></table>
 	  </div>
 	</div>
 </div>
</div>
</div>

<script>
var param=zfesLayerEditDg.getLayerParam();
var jqTableDomA=$("#ownOrganizationTable");
var jqFormDomA=$("#organizationSearchFromA");
var jqToolbarDomA=$("#ownSysOrganizationToolbar");
var isInOrganization="inOrganization";
var organizationId=param.id;
var initUrlA=host_auth+"/sys/sysOrganization/loadUserForOrganization?organizationId="+organizationId+"&isInOrganization="+isInOrganization;

var jqTableDomB=$("#notOrganizationTable");
var jqFormDomB=$("#organizationSearchFormB");
var jqToolbarDomB=$("#notOwnSysOrganizationToolbar");
var isInOrganization="notInOrganization";
var initUrlB=host_auth+"/sys/sysOrganization/loadUserForOrganization?organizationId="+organizationId+"&isInOrganization="+isInOrganization;

$(function(){
	initData();
});
function initData(){
	var columns=[
					{checkbox:true},
					{field:'perName',title:'姓名',width:60},
					{field:'perNum',title:'编号',width:60},
				];
	zfesBstable.laodTable(jqTableDomA,jqFormDomA,jqToolbarDomA,initUrlA,columns,{height:500});
	zfesBstable.laodTable(jqTableDomB,jqFormDomB,jqToolbarDomB,initUrlB,columns,{height:500});
}
function removeFromOrganization(){
	 
	 var ids=zfesBstable.getRowIds(jqTableDomA);
	 alertSwal.confirm("移除人员","是否从本组织机构中移除",function(){
			 	var ajaxUrl = host_auth+"/sys/sysOrganization/removeUserFromOrganization";
				var param = { "userIds":ids,"organizationId":organizationId};
				zfesAjax.ajaxTodo(ajaxUrl, param, function(data) {
					alertSwal.successText(data.message);
	    			zfesBstable.refresh(jqTableDomA);
					zfesBstable.refresh(jqTableDomB);
				}); 
	 });
 }
function addToOrganization(){
	var ids=zfesBstable.getRowIds(jqTableDomB);
	 alertSwal.confirm("增加人员","是否为本组织机构增加人员",function(){
			 	var ajaxUrl = host_auth+"/sys/sysOrganization/addUserToOrganization";
			 	var param = { "userIds":ids,"organizationId":organizationId};
				zfesAjax.ajaxTodo(ajaxUrl, param, function(data) {
					alertSwal.successText(data.message);
	    			//layer.close(layer.index);
	    			zfesBstable.refresh(jqTableDomA);
					zfesBstable.refresh(jqTableDomB);
				}); 
	 });
}


function searchA(){
	zfesBstable.reload(jqTableDomA);
}

function searchB(){
	zfesBstable.reload(jqTableDomB);
}
</script>

 </div>
 


